package 力扣日常刷题.木22一月.第12天0120;

/**
 * @author 帅小伙
 * @date 2022/1/20
 * @description
 * https://leetcode-cn.com/problems/stone-game-ix/
 * https://leetcode-cn.com/problems/stone-game-ix/solution/shi-zi-you-xi-ix-by-leetcode-solution-kk5f/
 */
public class Demo28博弈论中等石子游戏9 {


    public boolean stoneGameIX(int[] stones) {
        int[] arr = new int[3];
        for (int val : stones) {
            int type = val %3;
            arr[type] ++;
        }
        if(arr[0] %2 == 0){
            return arr[1] >= 1 && arr[2] >= 1;
        }
        return arr[1] - arr[2] > 2 || arr[2] - arr[1] > 2;
    }

}
